﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CompaniesByMaster.aspx.cs" Inherits="GPSTrackingWebsiteManager.Manager.Pages.CompaniesByMaster" %>

<%@ Register Src="~/Manager/UserControls/CompanySearch.ascx" TagName="CompanySearch" TagPrefix="uc2" %>

<!DOCTYPE html>

<link href="../../Css/GPSTrackingWebsite.css" rel="stylesheet" />
<link href="../../Css/messi.css" rel="stylesheet" />
<script src="../../Javascript/jquery-1.11.1.min.js"></script>
<script src="../../Javascript/messi.js"></script>
<script src="../../Javascript/Custom.js"></script>
<script src="../../Javascript/WindowMessageManager.js"></script>

<html xmlns="http://www.w3.org/1999/xhtml">

<telerik:RadScriptBlock ID="RadScriptBlock3" runat="server">
    <script type="text/javascript">
        function resizeGrid() {
            //objWindowsMessageManager.show_Warning('message','title');
            var height = (window.innerHeight) - 25;
            var tableView = $find("<%=CompanyGridLinks.ClientID %>");
            tableView.get_element().style.height = (height) / 2 + "px";

            var tableView2 = $find("<%=MastersGrid.ClientID %>");
            tableView2.get_element().style.height = (height - (height) / 2) + "px";

            document.getElementById('HiddenFieldHeight').value = (window.innerHeight);
        }

        //Windows Message Manager 
        var objWindowsMessageManager = new WindowsMessageManager();

    </script>
</telerik:RadScriptBlock>

<head runat="server">
    <title>Compañias por Master</title>
</head>
<body onresize="resizeGrid()" style="overflow: hidden">
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>

         <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="MastersGrid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rmpCompaniesByMasters" LoadingPanelID="RadAjaxLoadingPanel1" UpdatePanelCssClass="" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="CompanyGridLinks">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="CompanyGridLinks" LoadingPanelID="RadAjaxLoadingPanel1" UpdatePanelCssClass="" />
                        <telerik:AjaxUpdatedControl ControlID="HiddenFieldError" LoadingPanelID="RadAjaxLoadingPanel1" UpdatePanelCssClass=""  /> 
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"></telerik:RadAjaxLoadingPanel>
        <asp:HiddenField ID="HiddenFieldHeight" runat="server" Value="517" />
        <asp:HiddenField ID="HiddenFieldError" runat="server" Value="" />

        <telerik:RadTabStrip ID="rtsCompaniesByMasters" runat="server" SelectedIndex="0" MultiPageID="rmpCompaniesByMasters" ></telerik:RadTabStrip>
        <telerik:RadMultiPage ID="rmpCompaniesByMasters" runat="server" SelectedIndex="0">
        <telerik:RadPageView ID="rpvCompaniesByMasters" runat="server">

        <telerik:RadGrid ID="MastersGrid" runat="server" AllowSorting="true" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" Height="100%" Width="100%" GroupingSettings-CaseSensitive="false" OnNeedDataSource="MastersGrid_NeedDataSource" OnSelectedIndexChanged="MastersGrid_SelectedIndexChanged" OnItemCommand="MastersGrid_ItemCommand">
                   <MasterTableView EditMode="PopUp" EditFormSettings-PopUpSettings-Modal="true" EditFormSettings-CaptionFormatString="Modo Edición" CommandItemDisplay="TopAndBottom" NoMasterRecordsText="No hay registros" AllowFilteringByColumn="true" TableLayout="Auto">
                    <CommandItemTemplate>
                        <div style="padding: 5px 5px;"> Masters: 
                            <asp:LinkButton ID="lbClearMasterFilters" runat="server" OnClick="lbClearMasterFilters_Click"  Visible='<%# !MastersGrid.MasterTableView.IsItemInserted %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/mixx-icon.png"/>Limpiar Filtros</asp:LinkButton>                                                                               
                        </div>                        
                    </CommandItemTemplate>
                        <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                            <HeaderStyle Width="20px"></HeaderStyle>
                        </RowIndicatorColumn>

                        <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                            <HeaderStyle Width="20px"></HeaderStyle>
                        </ExpandCollapseColumn>

                        <Columns>
                            <telerik:GridButtonColumn UniqueName="SelectColumn" CommandName="Select" Text="Seleccionar" HeaderStyle-Width="20px" ButtonType="ImageButton" ImageUrl="../../Template/Icons/16px/User-Group-Blue-icon.png" />
                            <telerik:GridBoundColumn DataField="MasterUsername" HeaderText="Master Username" UniqueName="MasterUsername"  ForceExtractValue="Always" 
                                 FilterControlWidth="130px" CurrentFilterFunction="Contains" ShowFilterIcon="false"  HeaderStyle-Width="150px" AutoPostBackOnFilter="true">
                                 <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                    <RequiredFieldValidator ForeColor="Red" ErrorMessage="* Requerido" SetFocusOnError="true"></RequiredFieldValidator>
                                </ColumnValidationSettings>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Password" HeaderText="Contraseña" UniqueName="Password" Display="False" ForceExtractValue="Always"
                                 FilterControlWidth="50px" CurrentFilterFunction="Contains" ShowFilterIcon="false"  HeaderStyle-Width="70px" AutoPostBackOnFilter="true">                               
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Identification" HeaderText="Identificación" UniqueName="Identification"
                                 FilterControlWidth="70px" CurrentFilterFunction="EqualTo" ShowFilterIcon="false"  HeaderStyle-Width="100px" AutoPostBackOnFilter="true">
                                 <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                    <RequiredFieldValidator ForeColor="Red" ErrorMessage="* Requerido" SetFocusOnError="true"></RequiredFieldValidator>
                                </ColumnValidationSettings>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Name" HeaderText="Nombre" UniqueName="Name"
                                 FilterControlWidth="100px" CurrentFilterFunction="Contains" ShowFilterIcon="false"  HeaderStyle-Width="130px" AutoPostBackOnFilter="true">
                                 <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                    <RequiredFieldValidator ForeColor="Red" ErrorMessage="* Requerido" SetFocusOnError="true"></RequiredFieldValidator>
                                </ColumnValidationSettings>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="FirstName" HeaderText="Primer Apellido" UniqueName="FirstName"
                                 FilterControlWidth="100px" CurrentFilterFunction="Contains" ShowFilterIcon="false"  HeaderStyle-Width="130px" AutoPostBackOnFilter="true">
                                 <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                    <RequiredFieldValidator ForeColor="Red" ErrorMessage="* Requerido" SetFocusOnError="true"></RequiredFieldValidator>
                                </ColumnValidationSettings>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="LastName" HeaderText="Segundo Apellido" UniqueName="LastName"
                                 FilterControlWidth="100px" CurrentFilterFunction="Contains" ShowFilterIcon="false"  HeaderStyle-Width="130px" AutoPostBackOnFilter="true">
                                 <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                    <RequiredFieldValidator ForeColor="Red" ErrorMessage="* Requerido" SetFocusOnError="true"></RequiredFieldValidator>
                                </ColumnValidationSettings>
                            </telerik:GridBoundColumn>                            
                        </Columns>

                        <EditFormSettings>
                            <EditColumn InsertText="Agregar" UpdateText="Actualizar" CancelText="Cancelar" ButtonType="ImageButton"></EditColumn>
                        </EditFormSettings>
                    </MasterTableView>
                       <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true">
                    <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True"></Scrolling>
                     <Selecting AllowRowSelect="True"></Selecting><ClientEvents OnPopUpShowing="PopUpShowing" />
                </ClientSettings>
                <FilterMenu EnableImageSprites="False"></FilterMenu>
                </telerik:RadGrid>

        <br/>
            <telerik:RadGrid ID="CompanyGridLinks" runat="server" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" Height="100%" Width="100%" OnDeleteCommand="CompanyGridLinks_DeleteCommand" AllowSorting="true" GroupingSettings-CaseSensitive="false" OnNeedDataSource="CompanyGridLinks_NeedDataSource">
            <ClientSettings EnableRowHoverStyle="true">
                                <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True">
                                </Scrolling>  <Selecting AllowRowSelect="True"></Selecting><ClientEvents OnPopUpShowing="PopUpShowing" />
            </ClientSettings>     
                    <MasterTableView EditMode="PopUp" EditFormSettings-PopUpSettings-Modal="true" EditFormSettings-CaptionFormatString="Modo Edición" CommandItemDisplay="TopAndBottom" NoMasterRecordsText="No hay registros" AllowFilteringByColumn="true" TableLayout="Auto">
                    <CommandItemTemplate>
                        <div style="padding: 5px 5px;"> Compañias asociadas al Master: 
                            <asp:LinkButton ID="lbAddCompany" runat="server" OnClientClick="OpenCompanySearch()"><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/text-plus-icon.png"/>Asociar más Compañías</asp:LinkButton>     
                            <asp:LinkButton ID="lbClearCompaniesFilters" runat="server" OnClick="lbClearCompaniesFilters_Click"  Visible='<%# !CompanyGridLinks.MasterTableView.IsItemInserted %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/mixx-icon.png"/>Limpiar Filtros</asp:LinkButton>                                                                               
				            <asp:LinkButton ID="lbShowError" runat="server" OnClick="lbShowError_Click" Visible='<%# HiddenFieldError.Value == string.Empty ? false : true %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/bug-icon.png"/>Error Técnico</asp:LinkButton>                                                                                                               
                        </div>                        
                    </CommandItemTemplate>

                                <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                                    <HeaderStyle Width="20px"></HeaderStyle>
                                </RowIndicatorColumn>

                                <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                                    <HeaderStyle Width="20px"></HeaderStyle>
                                </ExpandCollapseColumn>

                                <Columns>
                                    <telerik:GridButtonColumn HeaderStyle-Width="25px" ConfirmText="¿Desea eliminar el registro?" ConfirmDialogType="RadWindow" ConfirmDialogHeight="120" ConfirmDialogWidth="270" ConfirmTitle="Eliminar" ButtonType="ImageButton" CommandName="Delete" Text="Eliminar" ItemStyle-Width="20px" />
                                    <telerik:GridBoundColumn DataField="CompanyId" FilterControlAltText="Filter MasterUsername column" HeaderText="Compañía ID" UniqueName="CompanyID" ItemStyle-Width="100px" HeaderStyle-Width="100px" FilterControlWidth="80px" CurrentFilterFunction="Contains" ShowFilterIcon="false" AutoPostBackOnFilter="true" Display="false">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="CompanyIdSource.Name" FilterControlAltText="Filter Name column" HeaderText="Nombre" UniqueName="CompanyIdSource.Name" ItemStyle-Width="200px" HeaderStyle-Width="200px" FilterControlWidth="180px" CurrentFilterFunction="Contains" ShowFilterIcon="false" AutoPostBackOnFilter="true" >
                                        </telerik:GridBoundColumn>
                                </Columns>

                                <EditFormSettings>
                                    <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                                </EditFormSettings>

                                <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
                            </MasterTableView>

                            <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
                  <ClientSettings>
                        <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True">
                        </Scrolling>
                    </ClientSettings>
                            <FilterMenu EnableImageSprites="False"></FilterMenu>
                        </telerik:RadGrid>

            </telerik:RadPageView>
            </telerik:RadMultiPage>

            <uc2:CompanySearch ID="uscCompanySearch" runat="server" IsMultipleSelects="true" CalledBy="CompaniesByMaster" IsClearGridAfterClose="true" OnOnAcceptEvent="uscCompanySearch_OnAcceptEvent" OnOnCancelEvent="uscCompanySearch_OnCancelEvent"/>              
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>       
    </form>
</body>
</html>
